package com.microstrategy.database.hbase.model;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import com.microstrategy.database.hbase.dao.RegionOfTableOnEachRSDAO;

public class RegionOfTableOnEachRSServer {

	private String timestamp;
	private String rsname; // region server name
	private String tablename; // table name
	private String regionname; // region name
	private String memstoresize; // memstore size
	private String storesize; // total size of store file size
	private String storenumber; // # of store files
	private String storefileindexsize;

	public RegionOfTableOnEachRSServer() {
		super();
	}

	public RegionOfTableOnEachRSServer(String timestamp, String rsname,
			String tablename, String regionname, String memstoresize,
			String storesize, String storenumber, String storefileindexsize) {
		super();
		this.timestamp = timestamp;
		this.rsname = rsname;
		this.tablename = tablename;
		this.regionname = regionname;
		this.memstoresize = memstoresize;
		this.storesize = storesize;
		this.storenumber = storenumber;
		this.storefileindexsize = storefileindexsize;
	}

	public String getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

	public String getRsname() {
		return rsname;
	}

	public void setRsname(String rsname) {
		this.rsname = rsname;
	}

	public String getTablename() {
		return tablename;
	}

	public void setTablename(String tablename) {
		this.tablename = tablename;
	}

	public String getRegionname() {
		return regionname;
	}

	public void setRegionname(String regionname) {
		this.regionname = regionname;
	}

	public String getMemstoresize() {
		return memstoresize;
	}

	public void setMemstoresize(String memstoresize) {
		this.memstoresize = memstoresize;
	}

	public String getStoresize() {
		return storesize;
	}

	public void setStoresize(String storesize) {
		this.storesize = storesize;
	}

	public String getStorenumber() {
		return storenumber;
	}

	public void setStorenumber(String storenumber) {
		this.storenumber = storenumber;
	}

	public String getStorefileindexsize() {
		return storefileindexsize;
	}

	public void setStorefileindexsize(String storefileindexsize) {
		this.storefileindexsize = storefileindexsize;
	}

	static RegionOfTableOnEachRSDAO dao = new RegionOfTableOnEachRSDAO();

	public void Save() {
		dao.insert(this);
	}

	public static List<RegionOfTableOnEachRSServer> GetRecent(int n) {
		return dao.selectRecentN(n);
	}

	@Override
	public String toString() {
		return "RegionOfTableOnEachRSServer [timestamp=" + timestamp
				+ ", rsname=" + rsname + ", tablename=" + tablename
				+ ", regionname=" + regionname + ", memstoresize="
				+ memstoresize + ", storesize=" + storesize + ", storenumber="
				+ storenumber + ", storefileindexsize=" + storefileindexsize
				+ "]";
	}

	public static void main(String args[]) {

		// RegionOfTableOnEachRSServer rtrs = new RegionOfTableOnEachRSServer(
		// new Timestamp(new Date().getTime()).toString(), "rs-name",
		// "User", "rsname1", 12 + "", 132 + "", 3 + "", 12 + "");
		// rtrs.Save();
		//
		// for(int i = 1 ; i < 11; i++){
		// rtrs = new RegionOfTableOnEachRSServer(
		// new Timestamp(new Date().getTime() + 1000 * i).toString(), "rs-name",
		// "User", "rsname1", 12 + "", 132 + "", 3 + "", 12 + "");
		// rtrs.Save();
		// }

		RegionOfTableOnEachRSDAO dao = new RegionOfTableOnEachRSDAO();
		// test select
		List<RegionOfTableOnEachRSServer> rses = RegionOfTableOnEachRSServer
				.GetRecent(2);
		for (RegionOfTableOnEachRSServer rs : rses) {
			System.out.println(rs);
		}

	}
}
